package cn.hnbjx.prepaid.dao;

import cn.hnbjx.prepaid.pojo.File;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
@Mapper
public interface FileDao {

    //查询所有文件
    @Select("select * from `file` order by id desc")
    List<File> findByFileAll();

    //根据hash值查询
    @Select("select * from `file` where hash = #{hash}")
    File findByFileHash(String hash);

    //删除所有文件
    @Delete("delete from `file` where id = #{id}")
    int DeleteFile(Integer id);

    //添加file
    @Insert("INSERT INTO `file` (hash,url,`type`) VALUES (#{hash},#{url},#{type})")
    int addFile(File file);


}